package com.shan.oss.constant;

/**
 * Author: shanzheng <br/>
 * Description: oss系统接口结果常量枚举类<br/>
 * Date： 14:04 2017/9/6.<br/>
 * Modified By: <br/>
 */
public enum OssResultConstant {
    FAILED(0, "failled"),
    SUCCESS(1, "success");

    public int code;

    public String message;

    OssResultConstant(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * Description: 通过枚举code获取枚举类型
     *
     * @param code 枚举code值
     * @author: shanzheng
     * @date: 15:39 2017/9/6
     * @return: com.shan.oss.constant.OssResultConstant
     */
    public static OssResultConstant getEnum(int code) {
        OssResultConstant ossResultConstant = null;
        OssResultConstant[] enums = OssResultConstant.values();
        for (int i = 0; i < enums.length; i++) {
            if (enums[i].getCode() == code) {
                ossResultConstant = enums[i];
                break;
            }
        }
        return ossResultConstant;
    }

}
